Firebase Data Push Experiement

This is a notebook to experiment with pushing data to Firebase using our functions.


In [1]:
%run 'analyseArticle.ipynb'
%run 'Firebase.ipynb'

In [3]:
parameters = analyseArticle("http://www.cnn.com/2013/11/27/justice/tucson-arizona-captive-girls/")

sendToFirebase(parameters["title"], parameters["url"], parameters["authors"]
               , parameters["date"], parameters["summary"], parameters["polarity"], 
               parameters["subjectivity"], parameters["keywords"], parameters["images"], parameters["videos"]
               , parameters["text"].replace("/",""))


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-25ffce566ca6> in <module>()
      4                , parameters["date"], parameters["summary"], parameters["polarity"],
      5                parameters["subjectivity"], parameters["keywords"], parameters["images"], parameters["videos"]
----> 6                , parameters["text"].replace("/",""))

<ipython-input-1-3719ce1eef1f> in sendToFirebase(title, url, authors, date, summary, polarity, subjectivity, keywords, images, videos, text)
     15         "text": text
     16     }
---> 17     results = db.child("articles").child(domain).set(data)

/usr/local/lib/python3.5/dist-packages/pyrebase/pyrebase.py in set(self, data, token, json_kwargs)
    298         self.path = ""
    299         headers = self.build_headers(token)
--> 300         request_object = self.requests.put(request_ref, headers=headers, data=json.dumps(data, **json_kwargs).encode("utf-8"))
    301         raise_detailed_error(request_object)
    302         return request_object.json()

/usr/lib/python3.5/json/__init__.py in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)
    228         cls is None and indent is None and separators is None and
    229         default is None and not sort_keys and not kw):
--> 230         return _default_encoder.encode(obj)
    231     if cls is None:
    232         cls = JSONEncoder

/usr/lib/python3.5/json/encoder.py in encode(self, o)
    196         # exceptions aren't as detailed.  The list call should be roughly
    197         # equivalent to the PySequence_Fast that ''.join() would do.
--> 198         chunks = self.iterencode(o, _one_shot=True)
    199         if not isinstance(chunks, (list, tuple)):
    200             chunks = list(chunks)

/usr/lib/python3.5/json/encoder.py in iterencode(self, o, _one_shot)
    254                 self.key_separator, self.item_separator, self.sort_keys,
    255                 self.skipkeys, _one_shot)
--> 256         return _iterencode(o, 0)
    257 
    258 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,

/usr/lib/python3.5/json/encoder.py in default(self, o)
    177 
    178         """
--> 179         raise TypeError(repr(o) + " is not JSON serializable")
    180 
    181     def encode(self, o):

TypeError: datetime.datetime(2013, 11, 27, 0, 0) is not JSON serializable

In [ ]: